package cn.zlj.pethome.org.service.impl;

import cn.zlj.pethome.basic.QueryResult;
import cn.zlj.pethome.org.domain.TEmployee;
import cn.zlj.pethome.org.mapper.EmployeeMapper;
import cn.zlj.pethome.org.query.QueryPage;
import cn.zlj.pethome.org.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class EmployeeServiceImpl implements EmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;


    @Override
    public List<TEmployee> getList() {
        return employeeMapper.getList();
    }

    @Override
    public QueryResult<TEmployee> queryPage(QueryPage page) {
        List<TEmployee> tEmployees = employeeMapper.queryPage(page);
        QueryResult<TEmployee> tEmployeeQueryResult = new QueryResult<>();
        tEmployeeQueryResult.setRows(tEmployees);
        Integer integer = this.queryPageCount(page);
        tEmployeeQueryResult.setTotals(integer);
        return tEmployeeQueryResult;
    }

    @Override
    public Integer queryPageCount(QueryPage page) {
        return employeeMapper.queryPageCount(page);
    }

    @Override
    @Transactional
    public void del(Long id) {
        employeeMapper.del(id);
    }

    @Override
    public TEmployee getOne(Long id) {
        return employeeMapper.getOne(id);
    }

    @Override
    @Transactional
    public void update(TEmployee tEmployee) {
       employeeMapper.update(tEmployee);
    }

    @Override
    @Transactional
    public void save(TEmployee tEmployee) {
        employeeMapper.save(tEmployee);
    }

    @Override
    public void batchDel(List<Long> ids) {
        employeeMapper.batchDel(ids);
    }

    @Override
    public TEmployee selectByLogininfoId(Long id) {
        return employeeMapper.selectByLogininfoId(id);
    }

    @Override
    public List<TEmployee> selectByShopId(Long shopId) {
        return employeeMapper.selectByShopId(shopId);
    }
}
